home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / Mark Pilgrim / Brailler 0.5ß / Brailler 0.5ß.source / brlr ƒ / brlr grade 2 meat.c < prev    next >
Encoding:
Text File  |  1994-10-30  |  17.3 KB  |  474 lines  |  [TEXT/MMCC]

  1. //things to deal with:
  2. //multi-digit numbers
  3.  
  4. #include "brlr grade 2 meat.h"
  5. #include "brlr conversion.h"
  6. #include "util.h"
  7.  
  8. Boolean            gPostingEvents;
  9. short            gCharsToPost;
  10. short            gGrade;
  11.  
  12. static    void DealWithNonAlpha(unsigned char *a, short len, short *offset);
  13. static    short DealWithCapitals(unsigned char *a, short len, short offset);
  14. static    Boolean DealWithWholeWord(unsigned char *a, short offset, short wordLength);
  15. static    Boolean DealWithPartialWord(unsigned char *a, short offset, short wordLength,
  16.             Boolean startOfWord, short *p);
  17. static    void AddString(Str255 theStr);
  18. static    void AddCharacter(unsigned char theChar);
  19. static    void AddDots(Str31 dotStr);
  20. static    Boolean MatchWord(Str255 oneStr, Str255 twoStr);
  21. static    Boolean MatchPartial(unsigned char *a, short *foundLength, Str255 theStr);
  22.  
  23. static    Boolean            gSuppressSpace;
  24.  
  25. void DealWithGrade2Word(TEHandle hTE)
  26. {
  27.     unsigned char    *a;
  28.     short            len;
  29.     short            offset;
  30.     short            wordLength;
  31.     short            partialLength;
  32.     Boolean            startOfWord;
  33.     
  34.     HLock((**hTE).hText);
  35.     a=(unsigned char*)(*((**hTE).hText));
  36.     len=(**hTE).teLength;
  37.     if (len==0)
  38.         return;
  39.     
  40.     gPostingEvents=TRUE;
  41.     gCharsToPost=0;
  42.     gSuppressSpace=FALSE;
  43.     offset=0;
  44.     
  45.     while (offset<len)
  46.     {
  47.         DealWithNonAlpha(a, len, &offset);
  48.         /* offset should now point to first letter in a word */
  49.         if (offset<len)
  50.         {
  51.             wordLength=DealWithCapitals(a, len, offset);
  52.             /* now offset should still point to first letter in a, but the word it
  53.                points to has been converted to lowercase; the length of the word is
  54.                returned and stored in wordLength */
  55.             if (!DealWithWholeWord(a, offset, wordLength))
  56.             {    /* didn't find whole word contraction, so check for partial ones */
  57.                 /* offset is still pointing to the first character in this word */
  58.                 startOfWord=TRUE;
  59.                 while (wordLength>0)
  60.                 {
  61.                     if (!DealWithPartialWord(a, offset, wordLength, startOfWord, &partialLength))
  62.                     {    /* didn't find partial word contraction; just add character
  63.                            and go on to the next one */
  64.                         AddCharacter(a[offset++]);
  65.                         wordLength--;
  66.                     }
  67.                     else
  68.                     {    /* found partial contraction; update offset and wordLength */
  69.                         offset+=partialLength;
  70.                         wordLength-=partialLength;
  71.                     }
  72.                     startOfWord=FALSE;
  73.                 }
  74.             }
  75.             else
  76.             {    /* found whole word contraction and dealt with it; we'll update the
  77.                    offset ourselves to point to the next character after this word */
  78.                 offset+=wordLength;
  79.             }
  80.         }
  81.     }
  82.     
  83.     HUnlock((**hTE).hText);
  84. }
  85.  
  86. void DealWithNonAlpha(unsigned char *a, short len, short *offset)
  87. {
  88.     unsigned char    theChar;
  89.     
  90.     theChar=a[*offset];
  91.     if (gSuppressSpace)
  92.     {    /* some whole word contractions require no space after them: by, to, into */
  93.         if (theChar==' ')
  94.             theChar=a[++(*offset)];
  95.         gSuppressSpace=FALSE;
  96.     }
  97.     while (((*offset)<len) && (!(((theChar>='A') && (theChar<='Z')) || ((theChar>='a') && (theChar<='z')))))
  98.     {
  99.         AddCharacter(theChar);
  100.         theChar=a[++(*offset)];
  101.     }
  102. }
  103.  
  104. short DealWithCapitals(unsigned char *a, short len, short offset)
  105. /* checks for presence of single capital letter or all caps, then sets chars to lowercase */
  106. {
  107.     short            i;
  108.     Boolean            firstCaps, allCaps;
  109.     short            wordLength;
  110.     unsigned char    theChar;
  111.     
  112.     wordLength=0;
  113.     theChar=a[offset];
  114.     while ((offset+wordLength<len) &&
  115.             (((theChar>='A') && (theChar<='Z')) || ((theChar>='a') && (theChar<='z'))))
  116.     {
  117.         wordLength++;
  118.         theChar=a[offset+wordLength];
  119.     }
  120.     
  121.     allCaps=TRUE;
  122.     for (i=0; ((i<wordLength) && (allCaps)); i++)
  123.         if ((a[offset+i]>='a') && (a[offset+i]<='z'))
  124.             allCaps=FALSE;
  125.     
  126.     if (!allCaps)
  127.     {
  128.         firstCaps=((a[offset]>='A') && (a[offset]<='Z'));
  129.     }
  130.     
  131.     if (firstCaps || allCaps)
  132.         AddDots("\p6");
  133.     if ((allCaps) && (wordLength>1))
  134.         AddDots("\p6");
  135.     
  136.     for (i=0; i<wordLength; i++)
  137.         if ((a[offset+i]>='A') && (a[offset+i]<='Z'))
  138.             a[offset+i]|=0x20;
  139.     
  140.     return wordLength;
  141. }
  142.  
  143. Boolean DealWithWholeWord(unsigned char *a, short offset, short wordLength)
  144. {
  145.     Str255            theStr;
  146.     
  147.     theStr[0]=wordLength;
  148.     Mymemcpy((Ptr)&theStr[1], (Ptr)&a[offset], (wordLength>255) ? 256 : wordLength+1);
  149.     
  150.     if (MatchWord(theStr, "\pbut")) AddCharacter('b');
  151.     else if (MatchWord(theStr, "\pcan")) AddCharacter('c');
  152.     else if (MatchWord(theStr, "\pdo")) AddCharacter('d');
  153.     else if (MatchWord(theStr, "\pevery")) AddCharacter('e');
  154.     else if (MatchWord(theStr, "\pfrom")) AddCharacter('f');
  155.     else if (MatchWord(theStr, "\pgo")) AddCharacter('g');
  156.     else if (MatchWord(theStr, "\phave")) AddCharacter('h');
  157.     else if (MatchWord(theStr, "\pjust")) AddCharacter('j');
  158.     else if (MatchWord(theStr, "\pknowledge")) AddCharacter('k');
  159.     else if (MatchWord(theStr, "\plike")) AddCharacter('l');
  160.     else if (MatchWord(theStr, "\pmore")) AddCharacter('m');
  161.     else if (MatchWord(theStr, "\pnot")) AddCharacter('n');
  162.     else if (MatchWord(theStr, "\ppeople")) AddCharacter('p');
  163.     else if (MatchWord(theStr, "\pquite")) AddCharacter('q');
  164.     else if (MatchWord(theStr, "\prather")) AddCharacter('r');
  165.     else if (MatchWord(theStr, "\pso")) AddCharacter('s');
  166.     else if (MatchWord(theStr, "\pthat")) AddCharacter('t');
  167.     else if (MatchWord(theStr, "\pus")) AddCharacter('u');
  168.     else if (MatchWord(theStr, "\pvery")) AddCharacter('v');
  169.     else if (MatchWord(theStr, "\pwill")) AddCharacter('w');
  170.     else if (MatchWord(theStr, "\pit")) AddCharacter('x');
  171.     else if (MatchWord(theStr, "\pyou")) AddCharacter('y');
  172.     else if (MatchWord(theStr, "\pas")) AddCharacter('z');
  173.     else if (MatchWord(theStr, "\pwas")) AddDots("\p356");
  174.     else if (MatchWord(theStr, "\pwere")) AddDots("\p2356");
  175.     else if (MatchWord(theStr, "\phis")) AddDots("\p236");
  176.     else if (MatchWord(theStr, "\pby"))
  177.     {
  178.         AddDots("\p356");
  179.         gSuppressSpace=TRUE;
  180.     }
  181.     else if (MatchWord(theStr, "\pto"))
  182.     {
  183.         AddDots("\p235");
  184.         gSuppressSpace=TRUE;
  185.     }
  186.     else if (MatchWord(theStr, "\pinto"))
  187.     {
  188.         AddDots("\p35 235");
  189.         gSuppressSpace=TRUE;
  190.     }
  191.     else if (MatchWord(theStr, "\pchild")) AddDots("\p16");
  192.     else if (MatchWord(theStr, "\pshall")) AddDots("\p146");
  193.     else if (MatchWord(theStr, "\pthis")) AddDots("\p1456");
  194.     else if (MatchWord(theStr, "\pwhich")) AddDots("\p156");
  195.     else if (MatchWord(theStr, "\pour")) AddDots("\p1256");
  196.     else if (MatchWord(theStr, "\pstill")) AddDots("\p34");
  197.     else if (MatchWord(theStr, "\penough")) AddDots("\p26");
  198.     else if (MatchWord(theStr, "\pabout")) AddString("\pab");
  199.     else if (MatchWord(theStr, "\pabove")) AddString("\pabv");
  200.     else if (MatchWord(theStr, "\paccording")) AddString("\pac");
  201.     else if (MatchWord(theStr, "\pacross")) AddString("\pacr");
  202.     else if (MatchWord(theStr, "\pafter")) AddString("\paf");
  203.     else if (MatchWord(theStr, "\pafternoon")) AddString("\pafn");
  204.     else if (MatchWord(theStr, "\pafterward")) AddString("\pafw");
  205.     else if (MatchWord(theStr, "\pagain")) AddString("\pag");
  206.     else if (MatchWord(theStr, "\pagainst")) AddDots("\p1 1245 34");
  207.     else if (MatchWord(theStr, "\palmost")) AddString("\palm");
  208.     else if (MatchWord(theStr, "\palready")) AddString("\palr");
  209.     else if (MatchWord(theStr, "\palso")) AddString("\pal");
  210.     else if (MatchWord(theStr, "\palthough")) AddDots("\p1 123 1456");
  211.     else if (MatchWord(theStr, "\paltogether")) AddString("\palt");
  212.     else if (MatchWord(theStr, "\palways")) AddString("\palw");
  213.     else if (MatchWord(theStr, "\pbecause")) AddDots("\p23 14");
  214.     else if (MatchWord(theStr, "\pbefore")) AddDots("\p23 124");
  215.     else if (MatchWord(theStr, "\pbehind")) AddDots("\p23 125");
  216.     else if (MatchWord(theStr, "\pbelow")) AddDots("\p23 123");
  217.     else if (MatchWord(theStr, "\pbeneath")) AddDots("\p23 1345");
  218.     else if (MatchWord(theStr, "\pbeside")) AddDots("\p23 234");
  219.     else if (MatchWord(theStr, "\pbetween")) AddDots("\p23 2345");
  220.     else if (MatchWord(theStr, "\pbeyond")) AddDots("\p23 13456");
  221.     else if (MatchWord(theStr, "\pblind")) AddString("\pbl");
  222.     else if (MatchWord(theStr, "\pbraille")) AddString("\pbrl");
  223.     else if (MatchWord(theStr, "\pchildren")) AddDots("\p16 1345");
  224.     else if (MatchWord(theStr, "\pconceive")) AddDots("\p25 14 1236");
  225.     else if (MatchWord(theStr, "\pconceiving")) AddDots("\p25 14 1236 1245");
  226.     else if (MatchWord(theStr, "\pdeclare")) AddString("\pdcl");
  227.     else if (MatchWord(theStr, "\peither")) AddString("\pei");
  228.     else if (MatchWord(theStr, "\pfirst")) AddDots("\p124 34");
  229.     else if (MatchWord(theStr, "\pfriend")) AddString("\pfr");
  230.     else if (MatchWord(theStr, "\pgood")) AddString("\pgd");
  231.     else if (MatchWord(theStr, "\pgreat")) AddString("\pgrt");
  232.     else if (MatchWord(theStr, "\pherself")) AddDots("\p125 12456 124");
  233.     else if (MatchWord(theStr, "\phim")) AddString("\phm");
  234.     else if (MatchWord(theStr, "\phimself")) AddString("\phmf");
  235.     else if (MatchWord(theStr, "\pimmediate")) AddString("\pimm");
  236.     else if (MatchWord(theStr, "\pits")) AddString("\pxs");
  237.     else if (MatchWord(theStr, "\pitself")) AddString("\pxf");
  238.     else if (MatchWord(theStr, "\pletter")) AddString("\plr");
  239.     else if (MatchWord(theStr, "\plittle")) AddString("\pll");
  240.     else if (MatchWord(theStr, "\pmuch")) AddDots("\p134 16");
  241.     else if (MatchWord(theStr, "\pmust")) AddDots("\p134 34");
  242.     else if (MatchWord(theStr, "\pmyself")) AddString("\pmyf");
  243.     else if (MatchWord(theStr, "\pnecessary")) AddString("\pnec");
  244.     else if (MatchWord(theStr, "\pneither")) AddString("\pnei");
  245. //    else if (MatchWord(theStr, "\po'clock")) AddString("\po'c");
  246.     else if (MatchWord(theStr, "\poneself")) AddDots("\p5 135 124");
  247.     else if (MatchWord(theStr, "\pourselves")) AddDots("\p1256 1235 1236 234");
  248.     else if (MatchWord(theStr, "\ppaid")) AddString("\ppd");
  249.     else if (MatchWord(theStr, "\pperceive")) AddDots("\p1234 12456 14 1236");
  250.     else if (MatchWord(theStr, "\pperceiving")) AddDots("\p1234 12456 14 1236 1245");
  251.     else if (MatchWord(theStr, "\pperhaps")) AddDots("\p1234 12456 125");
  252.     else if (MatchWord(theStr, "\pquick")) AddString("\pqk");
  253.     else if (MatchWord(theStr, "\preceive")) AddString("\prcv");
  254.     else if (MatchWord(theStr, "\preceiving")) AddString("\prcvg");
  255.     else if (MatchWord(theStr, "\prejoice")) AddString("\prjc");
  256.     else if (MatchWord(theStr, "\prejoicing")) AddString("\prjcg");
  257.     else if (MatchWord(theStr, "\psaid")) AddString("\psd");
  258.     else if (MatchWord(theStr, "\pshould")) AddDots("\p146 145");
  259.     else if (MatchWord(theStr, "\psuch")) AddDots("\p234 16");
  260.     else if (MatchWord(theStr, "\pthemselves")) AddDots("\p2346 134 1236 234");
  261.     else if (MatchWord(theStr, "\pthyself")) AddDots("\p1456 13456 124");
  262.     else if (MatchWord(theStr, "\ptoday")) AddString("\ptd");
  263.     else if (MatchWord(theStr, "\ptogether")) AddString("\ptgr");
  264.     else if (MatchWord(theStr, "\ptomorrow")) AddString("\ptm");
  265.     else if (MatchWord(theStr, "\ptonight")) AddString("\ptn");
  266.     else if (MatchWord(theStr, "\pwould")) AddString("\pwd");
  267.     else if (MatchWord(theStr, "\pyour")) AddString("\pyr");
  268.     else if (MatchWord(theStr, "\pyourself")) AddString("\pyrf");
  269.     else if (MatchWord(theStr, "\pyourselves")) AddString("\pyrvs");
  270.     else if (MatchWord(theStr, "\pbeen")) AddDots("\p12 15 26");
  271.     else return FALSE;
  272.     
  273.     return TRUE;
  274. }
  275.  
  276. Boolean DealWithPartialWord(unsigned char *a, short offset, short wordLength,
  277.     Boolean startOfWord, short *p)
  278. {
  279.     unsigned char    *b;
  280.     
  281.     b=(unsigned char*)&a[offset];
  282.     *p=0;
  283.     
  284.     if (wordLength>=9)
  285.     {
  286.         if (MatchPartial(b, p, "\pcharacter")) AddDots("\p5 16");
  287.     }
  288.     if ((wordLength>=8) && ((*p)==0))
  289.     {
  290.         if (MatchPartial(b, p, "\pquestion")) AddDots("\p5 12345");
  291.     }
  292.     if ((wordLength>=7) && ((*p)==0))
  293.     {
  294.         if (MatchPartial(b, p, "\pthrough")) AddDots("\p5 1456");
  295.     }
  296.     if ((wordLength>=6) && ((*p)==0))
  297.     {
  298.         if (MatchPartial(b, p, "\pfather")) AddDots("\p5 124");
  299.         else if (MatchPartial(b, p, "\pmother")) AddDots("\p5 134");
  300.         else if (MatchPartial(b, p, "\pcannot")) AddDots("\p456 14");
  301.         else if (MatchPartial(b, p, "\pspirit")) AddDots("\p456 234");
  302.     }
  303.     if ((wordLength>=5) && ((*p)==0))
  304.     {
  305.         if (MatchPartial(b, p, "\pation")) AddDots("\p6 1345");
  306.         else if (MatchPartial(b, p, "\pright")) AddDots("\p5 1235");
  307.         else if (MatchPartial(b, p, "\punder")) AddDots("\p5 136");
  308.         else if (MatchPartial(b, p, "\pyoung")) AddDots("\p5 13456");
  309.         else if (MatchPartial(b, p, "\pthere")) AddDots("\p5 2346");
  310.         else if (MatchPartial(b, p, "\pwhere")) AddDots("\p5 156");
  311.         else if (MatchPartial(b, p, "\pought")) AddDots("\p5 1256");
  312.         else if (MatchPartial(b, p, "\pthese")) AddDots("\p45 2346");
  313.         else if (MatchPartial(b, p, "\pthose")) AddDots("\p45 1456");
  314.         else if (MatchPartial(b, p, "\pwhose")) AddDots("\p45 156");
  315.         else if (MatchPartial(b, p, "\pworld")) AddDots("\p456 2456");
  316.         else if (MatchPartial(b, p, "\ptheir")) AddDots("\p456 2346");
  317.     }
  318.     if ((wordLength>=4) && ((*p)==0))
  319.     {
  320.         if (MatchPartial(b, p, "\pwith")) AddDots("\p23456");
  321.         else if (MatchPartial(b, p, "\pound")) AddDots("\p46 145");
  322.         else if (MatchPartial(b, p, "\pance")) AddDots("\p46 15");
  323.         else if (MatchPartial(b, p, "\psion")) AddDots("\p46 1345");
  324.         else if (MatchPartial(b, p, "\pless")) AddDots("\p46 234");
  325.         else if (MatchPartial(b, p, "\pount")) AddDots("\p46 2345");
  326.         else if (MatchPartial(b, p, "\pence")) AddDots("\p56 15");
  327.         else if (MatchPartial(b, p, "\ption")) AddDots("\p56 1345");
  328.         else if (MatchPartial(b, p, "\pness")) AddDots("\p56 234");
  329.         else if (MatchPartial(b, p, "\pment")) AddDots("\p56 2345");
  330.         else if (MatchPartial(b, p, "\pally")) AddDots("\p6 13456");
  331.         else if (MatchPartial(b, p, "\pever")) AddDots("\p5 15");
  332.         else if (MatchPartial(b, p, "\phere")) AddDots("\p5 125");
  333.         else if (MatchPartial(b, p, "\pknow")) AddDots("\p5 13");
  334.         else if (MatchPartial(b, p, "\plord")) AddDots("\p5 123");
  335.         else if (MatchPartial(b, p, "\pname")) AddDots("\p5 1345");
  336.         else if (MatchPartial(b, p, "\ppart")) AddDots("\p5 1234");
  337.         else if (MatchPartial(b, p, "\psome")) AddDots("\p5 234");
  338.         else if (MatchPartial(b, p, "\ptime")) AddDots("\p5 2345");
  339.         else if (MatchPartial(b, p, "\pword")) AddDots("\p5 2456");
  340.         else if (MatchPartial(b, p, "\pupon")) AddDots("\p45 136");
  341.         else if (MatchPartial(b, p, "\pmany")) AddDots("\p456 134");
  342.     }
  343.     if ((wordLength>=3) && ((*p)==0))
  344.     {
  345.         if (MatchPartial(b, p, "\pong")) AddDots("\p56 1245");
  346.         else if (MatchPartial(b, p, "\pful")) AddDots("\p56 123");
  347.         else if (MatchPartial(b, p, "\pily")) AddDots("\p56 13456");
  348.         else if (MatchPartial(b, p, "\pday")) AddDots("\p5 145");
  349.         else if (MatchPartial(b, p, "\pone")) AddDots("\p5 135");
  350.         else if (MatchPartial(b, p, "\phad")) AddDots("\p456 125");
  351.         else if (MatchPartial(b, p, "\ping")) AddDots("\p346");
  352.         else if (MatchPartial(b, p, "\pble")) AddDots("\p3456");
  353.         else if (MatchPartial(b, p, "\pcon")) AddDots("\p25");
  354.         else if (MatchPartial(b, p, "\pcom")) AddDots("\p36");
  355.         else if (MatchPartial(b, p, "\pdis")) AddDots("\p256");
  356.         else if (MatchPartial(b, p, "\pand")) AddDots("\p12346");
  357.         else if (MatchPartial(b, p, "\pfor")) AddDots("\p123456");
  358.         else if (MatchPartial(b, p, "\pthe")) AddDots("\p2346");
  359.         else if (MatchPartial(b, p, "\pear")) AddDots("\p15 345");    /* precedence */
  360.         else if (MatchPartial(b, p, "\pain")) AddString("\pain");    /* don't use 'in' contraction */
  361.         else if (MatchPartial(b, p, "\pein")) AddString("\pein");
  362.         else if (MatchPartial(b, p, "\poin")) AddString("\poin");
  363.     }
  364.     if ((wordLength>=2) && ((*p)==0))
  365.     {
  366.         if (MatchPartial(b, p, "\pgh")) AddDots("\p126");
  367.         else if (MatchPartial(b, p, "\ped")) AddDots("\p1246");
  368.         else if (MatchPartial(b, p, "\per")) AddDots("\p12456");
  369.         else if (MatchPartial(b, p, "\pow")) AddDots("\p246");
  370.         else if (MatchPartial(b, p, "\par")) AddDots("\p345");
  371.         else if ((startOfWord) && (MatchPartial(b, p, "\pbe"))) AddDots("\p23");
  372.         else if ((startOfWord) && (MatchPartial(b, p, "\pin"))) AddDots("\p35");
  373.         else if ((wordLength>2) && (MatchPartial(b, p, "\pea"))) AddDots("\p2");
  374.         else if ((!startOfWord) && (MatchPartial(b, p, "\pbb"))) AddDots("\p23");
  375.         else if ((!startOfWord) && (MatchPartial(b, p, "\pcc"))) AddDots("\p25");
  376.         else if ((!startOfWord) && (MatchPartial(b, p, "\pdd"))) AddDots("\p256");
  377.         else if ((!startOfWord) && (MatchPartial(b, p, "\pff"))) AddDots("\p235");
  378.         else if ((!startOfWord) && (MatchPartial(b, p, "\pgg"))) AddDots("\p2356");
  379.         else if (MatchPartial(b, p, "\pof")) AddDots("\p12356");
  380.         else if (MatchPartial(b, p, "\pch")) AddDots("\p16");
  381.         else if (MatchPartial(b, p, "\psh")) AddDots("\p146");
  382.         else if (MatchPartial(b, p, "\pth")) AddDots("\p1456");
  383.         else if (MatchPartial(b, p, "\pwh")) AddDots("\p156");
  384.         else if (MatchPartial(b, p, "\pou")) AddDots("\p1256");
  385.         else if (MatchPartial(b, p, "\pst")) AddDots("\p34");
  386.         else if (MatchPartial(b, p, "\pen")) AddDots("\p26");
  387.     }
  388.     
  389.     return ((*p)!=0);
  390. }
  391.  
  392. void AddString(Str255 theStr)
  393. {
  394.     short            i;
  395.     
  396.     for (i=1; i<=theStr[0]; i++)
  397.         AddCharacter(theStr[i]);
  398. }
  399.  
  400. void AddCharacter(unsigned char theChar)
  401. {
  402.     unsigned char    brailleChar;
  403.     short            time, oldTime;
  404.     
  405.     time=1;
  406.     do
  407.     {
  408.         oldTime=time;
  409.         brailleChar=DealWithLetter(theChar, &time);
  410.         if (brailleChar!=0x00)
  411.         {
  412.             PostEvent(keyDown, brailleChar);
  413.             gCharsToPost++;
  414.         }
  415.     }
  416.     while (oldTime!=time);
  417. }
  418.  
  419. void AddDots(Str31 dotStr)
  420. {
  421.     Str31            oneStr;
  422.     short            i;
  423.     
  424.     i=1;
  425.     oneStr[0]=0x00;
  426.     while (i<=dotStr[0])
  427.     {
  428.         if (dotStr[i]==' ')
  429.         {
  430.             PostEvent(keyDown, Dots(oneStr));
  431.             gCharsToPost++;
  432.             oneStr[0]=0x00;
  433.         }
  434.         else oneStr[++oneStr[0]]=dotStr[i];
  435.         i++;
  436.     }
  437.     
  438.     if (oneStr[0]!=0x00)
  439.     {
  440.         PostEvent(keyDown, Dots(oneStr));
  441.         gCharsToPost++;
  442.     }
  443. }
  444.  
  445. Boolean MatchWord(Str255 oneStr, Str255 twoStr)
  446. {
  447.     short            i;
  448.     
  449.     i=0;
  450.     while ((i<=oneStr[0]) && (i<=twoStr[0]))
  451.     {
  452.         if (oneStr[i]!=twoStr[i])
  453.             return FALSE;
  454.         i++;
  455.     }
  456.     
  457.     return TRUE;
  458. }
  459.  
  460. Boolean MatchPartial(unsigned char *a, short *foundLength, Str255 theStr)
  461. /* guaranteed that a contains at least theStr[0] valid characters */
  462. /* if match is found, foundLength contains length of match on exit (theStr[0]) */
  463. /* if match is found, returns TRUE */
  464. {
  465.     short            i;
  466.     
  467.     for (i=0; i<theStr[0]; i++)
  468.         if (a[i]!=theStr[i+1])
  469.             return FALSE;
  470.     
  471.     *foundLength=theStr[0];
  472.     return TRUE;
  473. }
  474.